/*
 * StrahlentherapieVPrimitiveScorer3D.cc
 *
 *  Created on: Nov 27, 2010
 *      Author: holger
 */

#include "StrahlentherapieVPrimitiveScorer3D.hh"

StrahlentherapieVPrimitiveScorer3D::StrahlentherapieVPrimitiveScorer3D(G4String name, G4int ni, G4int nj, G4int nk, G4int depi, G4int depj, G4int depk) : G4VPrimitiveScorer(name)
{
	HCID = -1;
	fNi=ni;				fNj=nj;				fNk=nk;
	fDepthi = depi;		fDepthj = depj;		fDepthk = depk;
}

void StrahlentherapieVPrimitiveScorer3D::Initialize(G4HCofThisEvent * HCE)
{
	EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName());
	if(HCID < 0) {HCID = GetCollectionID(0);}
	HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
}

void StrahlentherapieVPrimitiveScorer3D::clear()
{
	EvtMap->clear();
}

G4int StrahlentherapieVPrimitiveScorer3D::GetIndex(G4TouchableHistory* ROhist)
{
	G4int i = ROhist->GetReplicaNumber(fDepthi);
	G4int j = ROhist->GetReplicaNumber(fDepthj);
	G4int k = ROhist->GetReplicaNumber(fDepthk);
	return i*fNj*fNk+j*fNk+k;
}

